/**
 * Copyright (c) 2012 Axa Holding Belgium, SA. All rights reserved.
 * This software is the confidential and proprietary information of the AXA Group.
 */
package chabernac.android.wordbattle.paint.boggle;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.view.View;
import chabernac.android.wordbattle.model.WordRaster;
import chabernac.android.wordbattle.paint.iDrawable;

public class BoggleWordRasterDrawable extends iDrawable {
  private final WordRaster myWordRaster;
  private final Paint myPaint = new Paint();
  
  private List<iDrawable> myLetterDrawables = new ArrayList<iDrawable>();
  
  public BoggleWordRasterDrawable( WordRaster aWordRaster ) {
    super();
    myWordRaster = aWordRaster;
    
    init();
    createLetterDrawables();
  }
  
  private void init(){
    myPaint.setStyle(Style.FILL);
    myPaint.setColor(Color.BLACK);
    myPaint.setAntiAlias(true);
  }
  
  private void createLetterDrawables(){
    for(int x=0;x<myWordRaster.getColumns();x++){
      for(int y=0;y<myWordRaster.getRows();y++){
        myLetterDrawables.add(new BoggleLetterDrawable( myWordRaster.getLetter( x, y ) ));
      }
    }
  }
  
  @Override
  public void paint( Canvas aCanvas, View aView ) {
    for(iDrawable theDrawable : myLetterDrawables){
      theDrawable.paint( aCanvas, aView );
    }
  
  }

}
